<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">


    <title></title>
    <!-- <link rel="stylesheet" type="text/css" href="//www.eccpos.com/theme/assets/global/plugins/bootstrap/css/bootstrap.min.css" /> -->

    <!-- <link rel="stylesheet" type="text/css" href="//www.eccpos.com/skin/skins/portal/login/login.css?v=84dfcf30126a9c6b6c8ca5df14471e4f" /> -->

    <!-- <script type="text/javascript" src="//www.eccpos.com/theme/assets/global/plugins/jquery.min.js"></script> -->

    <!-- <script type="text/javascript" src="//www.eccpos.com/skin/skins/portal/md5/md5-xsm.js"></script> -->

    <!-- <script type="text/javascript" src="//www.eccpos.com/skin/skins/portal/base64.js"></script> -->


    <link rel="stylesheet" type="text/css" href="../theme/eccpos/bootstrap.min.css" />

    <link rel="stylesheet" type="text/css" href="../theme/eccpos/login.css" />

    <script type="text/javascript" src="../theme/eccpos/jquery.min.js"></script>

    <script type="text/javascript" src="../theme/eccpos/md5-xsm.js"></script>

    <script type="text/javascript" src="../theme/eccpos/base64.js"></script>




    <script>
        var _ST = "https://www.eccpos.com/st";

        var _MRT = "http://www.eccpos.com/mrtauth";

        var apacheIp = "http://www.eccpos.com/";

        var isUseUc = "false";
        var ucUrl = "https://www.eccpos.com/server-user";
        var individuation = "common";

        var changeHttp = function(s) {
            return s.replace('http:', 'https:');
        };
        (function() {
            // var ishttps = 'https:' == document.location.protocol ? true : false;
            // var ishttps = true;
            // _ST = ishttps ? changeHttp(_ST) : _ST;
            // _MRT = ishttps ? changeHttp(_MRT) : _MRT;
            // apacheIp = ishttps ? changeHttp(apacheIp) : apacheIp;
            // ucUrl = ishttps ? changeHttp(ucUrl) : ucUrl;
        })();
    </script>

    <script>
        var en_ps, shearCodeKey;

        $(document).ready(function() {
            var $username = $("#uuuu");
            var $password = $("#pppp");
            var $valcode = $("#vvvv");

            if (localStorage.lastusername) {
                $username.val(localStorage.lastusername);
            }
            var error = GetQueryString("error");
            if (error) {
                var msg = decodeURIComponent(GetQueryString("msg"));
                if (error == '921') {
                    msg += "请用账号登录";
                }
                showError(msg);
            }



            if (!xssDefense()) {
                return false;
            }
            // var username = $.trim($username.val());
            // var password = $.trim($password.val());
            var username = "<?php echo $username ?>";
            var password = "<?php echo $password ?>";
            var valc = $.trim($valcode.val());
            en_ps = encode64(password);
            password = hex_md5(password);
            if (isUseUc === 'true') {
                password = hex_md5(password + valc);
                _ST = ucUrl;
            } else {
                password = hex_md5(password + valc.toUpperCase());
            }
            var data = new Object();
            data.j_mmrm = username;
            data.j_mcmm = password;
            data.j_valcode = valc;
            data.shearCodeKey = shearCodeKey;
            $.ajax({
                url: _ST + "/users/dologin/up",
                type: "post",
                dataType: "jsonp",
                jsonp: "jsonp",
                data: data,
                success: loginComplete,
                error: loginError
            });
            return false;

            function loginComplete(data) {

                data = encodeURI(data);
                console.log('data', data)

                // data1 = 'UTF8' + encodeURI(data);
                // var hurl = _MRT + "/sttokenconsumer?xmlStr=" + data1 + "&relayState=" + _MRT + "/stlogin/gohomepage&en_ps=" + en_ps;
                // console.log('zhuanma后的hurl', hurl);
                var win_url = new Object();
                win_url.MRT = _MRT;
                win_url.en_ps = en_ps;
                win_url.data = data;

                $.ajax({
                    url: "/get_data/pds/eccpos-get_token",
                    data: win_url,
                    contentType: 'application/x-www-form-urlencoded',
                    type: "post",
                });
            }


            function loginError(xhr, status) {
                loginFailed("登陆失败，无法连接到登陆服务器，请检查您的网络或与管理员联系。");
            }

            function loginFailed(msg) {
                $("#loginBtn").html('登录');
                $("#loginBtn").removeAttr("disabled");
                var str = "";
                if (typeof msg == "object") {
                    for (var x in msg) {
                        str += x + ":" + msg[x] + "\n";
                    }
                } else {
                    str = msg;
                }
                $("#vvvv").val("");
                refcode();
                if (str == 'loginWarnning.jsp') {
                    str = '请关闭浏览器重新登录！';
                }
                showError(str);
            }

            function showError(msg) {
                $("#message-alert").removeClass("hidden").find(".text").html(msg);
            }

            if ($("#message-alert .text").text() != "") {
                $("#message-alert").removeClass("hidden");
            }
            $("#message-alert .close").on("click", function() {
                $("#message-alert").addClass("hidden");
            })


            document.onkeydown = function(e) {
                var ev = document.all ? window.event : e;
                if (ev.keyCode == 13) {
                    $("#loginBtn").click();
                }
            }


            function xssDefense() {
                var userId = $("#uuuu").val().toUpperCase();
                var password = $("#pppp").val().toUpperCase();
                if (userId.indexOf("SCRIPT") > -1 || userId.indexOf("SRC") > -1 || userId.indexOf("IFRAME") > -1) {
                    alert("用户名不符合规范");
                    return false;
                }
                if (password.indexOf("SCRIPT") > -1 || userId.indexOf("SRC") > -1 || userId.indexOf("IFRAME") > -1) {
                    alert("密码不符合规范");
                    return false;
                }
                return true;
            }

            //控制主页在没有hash的情况下，左侧菜单的展开位置
            sessionStorage.menuHash = "1";

            // 刷新验证码
            function refcode() {
                if (isUseUc && isUseUc === 'true') {
                    var url = ucUrl + "/verify/getshearCodeKey";
                    var xhr = new XMLHttpRequest();
                    xhr.open('GET', url, true);
                    xhr.responseType = "json";
                    xhr.onload = function() {
                        if (this.status == 200) {
                            shearCodeKey = this.response.dataMap.shearCodeKey;
                            var img = document.getElementById('valcodeimg');
                            img.style.width = '80px';
                            img.style.height = '30px'
                            $("#valcodeimg").attr("src", ucUrl + "/verify/getNewShearCaptcha?shearCodeKey=" + shearCodeKey);
                        }
                    }
                    xhr.send();
                } else {
                    $("#valcodeimg").attr("src", _ST + "/users/forlogin/img?width=80&height=30&" + new Date().getTime());
                }
            }

            function checkKeyCode(keycode, arr) {
                if (keycode == 13 || keycode == 8 || keycode == 9)
                    return true;
                var b = false;
                for (var i = 0; i < arr.length; i++) {
                    if (keycode >= arr[i][0] && keycode <= arr[i][1]) {
                        b = true;
                        break;
                    }
                }
                return b;
            }

            // 验证码只能输入数字
            /* $("#vvvv").keypress(function (event) {
                 var code = event.keyCode || event.which || event.charCode;
                 return checkKeyCode(code, [[48, 57]]);
             });*/

            $("#valcodeimg").click(function() {
                refcode();
            });

            function newLoginFunc() {
                //判断当前登录方式
                var is_qrcode = $(".new-loginFunc").find(".qrcode-eccpos-icon").length;
                if (is_qrcode > 0) {

                    $(".wxLogin").css("display", "none");
                    $(".normalLogin").css("display", "inline-block")
                } else {
                    //请求微信获取二维码,默认顶层跳转
                    // var ishttps = 'https:' == document.location.protocol ? true : false;
                    var apache_ip = "//" + document.location.hostname + "/";
                    var obj = new WxLogin({
                        id: "wxLoginCode",
                        appid: "wx7390df7f110ca39f",
                        scope: "snsapi_login",
                        redirect_uri: 'http%3A%2F%2Fmeap.eccpos.com%2Fwsp%2Fmp%2Fauth%2Fwx7390df7f110ca39f%3FappCode%3Dpos%26userType%3D01%26rdurl%3Dhttp%3A%2F%2Fwww.eccpos.com%2Fmrtauth%2Flogin%2FwxEntrance%3F1%3D1',
                        state: "",
                        style: "",
                        href: apache_ip + "skin/skins/portal/login/codeLogin.css"
                    });

                    $(".wxLogin").css("display", "inline-block");
                    $(".normalLogin").css("display", "none");
                    $('iframe').css('width', '270px');
                    obj = null;
                }
            };

        });

        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg); //search,查询？后面的参数，并匹配正则
            if (r != null) return r[2];
            return null;
        }
    </script>
</head>

<body>
    <div class="welcome-title"> 欢迎使用 <span id="title-name"></span>终端系统！</div>
    <div class="login-container">
        <div class="container-img">
        </div>
        <div class="content normalLogin">
            <div class="logo">密码登录</div>
            <div id="message-alert" class="alert alert-danger hidden">
                <a class="close" href="#">×</a>
                <div class="text"></div>
            </div>
            <form id="form-signin" class="form-signin big">
                <div class="input-group form-group">
                    <span class="input-group-addon icon-user"></span>
                    <input type="text" class="form-control" placeholder="用户名" id="uuuu" name="uuuu" value="NYPOSADMIN" required autofocus>
                </div>
                <div class="input-group form-group">
                    <span class="input-group-addon icon-lock"></span>
                    <input type="password" class="form-control" placeholder="密码" id="pppp" name="pppp" value="inspur@2020" autocomplete="off" required>
                </div>


                <button id="loginBtn" class="btn btn-lg btn-primary btn-block" type="button">登录</button>
                <!--忘记密码入口 add by lqj-->
                <div class="forgetPass" style="margin-top: 6px;"><a href="login/resetpass/pageInit">忘记密码？</a></div>
            </form>
        </div>


    </div>
    <div id="copyright" style="text-align: center;margin-top: 5px;"></div>
    <script>
        if (isUseUc && isUseUc === 'true') {
            var url = ucUrl + "/verify/getshearCodeKey";
            var xhr = new XMLHttpRequest();
            xhr.open('GET', url, true);
            xhr.responseType = "json";
            xhr.onload = function() {
                if (this.status == 200) {
                    shearCodeKey = this.response.dataMap.shearCodeKey;
                    var img = document.getElementById('valcodeimg');
                    img.style.width = '80px';
                    img.style.height = '30px'
                    $("#valcodeimg").attr("src", ucUrl + "/verify/getNewShearCaptcha?shearCodeKey=" + shearCodeKey);
                }
            }
            xhr.send();
        } else {
            $("#valcodeimg").attr("src", _ST + "/users/forlogin/img?width=80&height=30&" + new Date().getTime());
        }
    </script>
</body>

</html>